<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>吃啥</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <!-- <link rel="shortcut icon" href="/favicon.ico"> -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="stylesheet" href="/css/reset.css">
    <link rel="stylesheet" href="/css/iconfont.css">

    <link rel="stylesheet" href="http://g.alicdn.com/msui/sm/0.6.2/css/sm.min.css">
    <link rel="stylesheet" href="http://g.alicdn.com/msui/sm/0.6.2/css/sm-extend.min.css">
    <link rel="stylesheet" href="http://g.alicdn.com/msui/sm/0.6.2/css/??sm.min.css,sm-extend.min.css">
</head>

<body>
    <div class="page">
        <header class="bar bar-nav">
            <a class="button button-link button-nav pull-left" href="/demos/card" data-transition='slide-out'>
                <span class="icon icon-left"></span>
                返回
            </a>
            <h1 class="title">手机号登录</h1>
        </header>
        <div class="content">
            <div class="content-block">
                <p><a href="#" class="open-preloader">Open Preloader</a></p>
                <p><a href="#" class="open-preloader-title">Open Preloader with custom title</a></p>
            </div>
            <!-- 这里是页面内容区 -->
            <div class="list-block">
                <ul>
                    <!-- Text inputs -->
                    <li>
                        <div class="item-content">
                            <div class="item-media"><i class="icon icon-form-email"></i></div>
                            <div class="item-inner">
                                <div class="item-title label">手机</div>
                                <div class="item-input">
                                    <input id="private_phone" name="private_phone" type="text" placeholder="请输入你的手机号" />
                                </div>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item-content">
                            <div class="item-media"><i class="icon icon-form-toggle"></i></div>
                            <div class="item-inner">
                                <div class="item-title label">获取验证码</div>
                                <div class="item-input">
                                    <p><a href="#" id="sendMessage" class="button button-fill">点击获取 </a></p>
                                </div>
                                <!-- <div class="time">60s</div> -->
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item-content">
                            <div class="item-media"><i class="icon icon-form-name"></i></div>
                            <div class="item-inner">
                                <div class="item-title label">验证码</div>
                                <div class="item-input">
                                    <input id="private_code" type="text" placeholder="请输入手机验证码">
                                </div>
                            </div>
                        </div>
                    </li>
                </ul>
            </div>
            <div class="content-block">
                <div class="row">
                    <div class="col-50"><a href="#" class="button button-big button-fill button-danger">取消</a></div>
                    <div class="col-50"><a onclick="submit()"
                            class="button button-big button-fill button-success">验证</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type='text/javascript' src='http://g.alicdn.com/sj/lib/zepto/zepto.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='http://g.alicdn.com/msui/sm/0.6.2/js/sm.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='http://g.alicdn.com/msui/sm/0.6.2/js/sm-extend.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='http://g.alicdn.com/msui/sm/0.6.2/js/??sm.min.js,sm-extend.min.js'
        charset='utf-8'></script>
    <script>
        // 加载提示框
        $(document).on('click', '.open-preloader', function () {
            $.showPreloader();
            setTimeout(function () {
                $.hidePreloader();
            }, 2000);
        });
        $(document).on('click', '.open-preloader-title', function () {
            $.showPreloader('Custom Title')
            setTimeout(function () {
                $.hidePreloader();
            }, 2000);
        });

        // 发送验证码
        
        document.getElementById('sendMessage').onclick = function () {
            const phone = document.getElementById("private_phone").value;
            // window.location.href = "/admin/register/sendMessage"
            $.ajax({
                type: 'POSt',
                url: '/admin/register/sendMessage',
                // data to be added to query string:
                data: {
                    phone: phone,
                },
                // type of data we are expecting in return:
                dataType: 'json',
                success: function (data) {
                    if(data.code == 'success'){
                        window.location.href = "/admin/register/1"
                    }else{
                        $.alert(data.msg);
                    }
                }
            })
            setTimeout(function () {
                settime(obj)
            }, 1000)
        }

        // 提交信息
        function submit() {
            $.showPreloader('正在提交')
            setTimeout(function () {
                $.hidePreloader();
            }, 2000);
            const phone = document.getElementById("private_phone").value;
            const code = document.getElementById("private_code").value;
            $.ajax({
                type: 'POST',
                url: '/admin/register/isTrueCode',
                // data to be added to query string:
                data: {
                    phone: phone,
                    code: code
                },
                // type of data we are expecting in return:
                dataType: 'json',
                success: function (data) {
                    console.log(data)
                    if(data.err == 0){
                        window.location.href = "/admin/register/2"
                    }else{
                        $.alert(data.msg);
                    }
                }
            })
        }


    </script>
</body>

</html>